Cap Options
CAP is a library to manage Service Bus and ServiceBus' storage. It has database and service bus implementations by default. This project also contain all implementations and they can be configured in appsettings.json.
Enable Cap
- Adding following section to root of your appsettings.json will enable Cap Initialization.
"CapOptions": {
"UseDatabase": "", // As sample: [ InMemory , EntityFramework , MsSQL , MySQL , PostgreSQL , MongoDB ]
"ConnectionStringName": "", // Connection String must be defined in "ConnectionStrings" section and name must be written here.
"UseBroker": "", // As sample: [ RabbitMQ, Kafka, AzureServiceBus ]
"BrokerConnectionStringName": ""
}
Define Database
You can use following databases for keep queue safe in a database.
- InMemory
- EntityFramework
- MsSQL
- MySQL
- PostgreSQL
- MongoDB
You should use these parameters for UserDatabase
field like following:
"CapOptions": {
"UseDatabase": "PostgreSQL",
"ConnectionStringName": "",
"UseBroker": "",
"BrokerConnectionStringName": ""
}
You need a connection string for database. DO NOT WRITE CONNECTION STRING DIRECTLY HERE. Just add your connection string to ConnectionStrings
section and call it here by its name.
{
"ConnectionStrings": {
"MyPostgreForCap" : "User ID=postgres;Password=12345678;Host=localhost;Port=5432;Database=CAP;"
},
"CapOptions": {
"UseDatabase": "PostgreSQL",
"ConnectionStringName": "MyPostgreForCap", // <-- Write here name from ConnectionStrings
"UseBroker": "",
"BrokerConnectionStringName": ""
}
}
Define Service Bus Broker
You can use following Service Buses to making communication between services:
- RabbitMQ
- Kafka
- AzureServiceBus
You should use these parameters for UseBroker
field like following:
"CapOptions": {
"UseDatabase": "PostgreSQL",
"ConnectionStringName": "MyPostgreForCap",
"UseBroker": "RabbitMQ", // <-- Here
"BrokerConnectionStringName": ""
}
You need a hostname or connection string or whatever its name. Just define it into ConnectionStrings
section of your appsettings.json
{
"ConnectionStrings": {
"MyPostgreForCap" : "User ID=postgres;Password=12345678;Host=localhost;Port=5432;Database=CAP;"
"MyRabbitMQForCap": "amqp://user:pass@host:10000/vhost",
},
"CapOptions": {
"UseDatabase": "PostgreSQL",
"ConnectionStringName": "MyPostgreForCap",
"UseBroker": "RabbitMQ",
"BrokerConnectionStringName": "MyRabbitMQForCap" // <-- Write here same name from ConnectionStrings
}
}